﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGsMaterialCache : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGsMaterialCache(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGsMaterialCache_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGsMaterialCache obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGsMaterialCache()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGsMaterialCache(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdGsMaterialCache cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsMaterialCache_cast(OdRxObject.getCPtr(pObj));
			OdGsMaterialCache result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsMaterialCache)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsMaterialCache)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsMaterialCache)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMaterialCache_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMaterialCache_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMaterialCache_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGsMaterialCache createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsMaterialCache_createObject__SWIG_0();
			OdGsMaterialCache result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsMaterialCache)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsMaterialCache)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsMaterialCache)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setBaseModel(OdGsBaseModel pModel)
		{
			GlobalsPINVOKE.OdGsMaterialCache_setBaseModel(this.swigCPtr, OdGsBaseModel.getCPtr(pModel));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGsBaseModel baseModel()
		{
			IntPtr intPtr = GlobalsPINVOKE.OdGsMaterialCache_baseModel__SWIG_0(this.swigCPtr);
			OdGsBaseModel result = (intPtr == IntPtr.Zero) ? null : new OdGsBaseModel(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGsMaterialCache createObject(OdGsBaseModel pModel)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsMaterialCache_createObject__SWIG_1(OdGsBaseModel.getCPtr(pModel));
			OdGsMaterialCache result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsMaterialCache)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsMaterialCache)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsMaterialCache)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsMaterialNode searchNode(OdDbStub mtl)
		{
			OdGsMaterialNode result = (OdGsMaterialNode)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMaterialCache_searchNode(this.swigCPtr, OdDbStub.getCPtr(mtl)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsMaterialNode currentNode()
		{
			OdGsMaterialNode result = (OdGsMaterialNode)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMaterialCache_currentNode(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setMaterial(OdGsBaseVectorizer view, OdDbStub mtl, bool bDontReinit)
		{
			GlobalsPINVOKE.OdGsMaterialCache_setMaterial__SWIG_0(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view), OdDbStub.getCPtr(mtl), bDontReinit);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setMaterial(OdGsBaseVectorizer view, OdDbStub mtl)
		{
			GlobalsPINVOKE.OdGsMaterialCache_setMaterial__SWIG_1(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view), OdDbStub.getCPtr(mtl));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setCurrentNode(OdGsMaterialNode curNode)
		{
			GlobalsPINVOKE.OdGsMaterialCache_setCurrentNode__SWIG_0(this.swigCPtr, OdGsMaterialNode.getCPtr(curNode));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setCurrentNode()
		{
			GlobalsPINVOKE.OdGsMaterialCache_setCurrentNode__SWIG_1(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool removeNode(OdDbStub mtl)
		{
			bool result = GlobalsPINVOKE.OdGsMaterialCache_removeNode__SWIG_0(this.swigCPtr, OdDbStub.getCPtr(mtl));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool removeNode(OdGsCache pCsh)
		{
			bool result = GlobalsPINVOKE.OdGsMaterialCache_removeNode__SWIG_1(this.swigCPtr, OdGsCache.getCPtr(pCsh));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public uint getCacheSize()
		{
			uint result = GlobalsPINVOKE.OdGsMaterialCache_getCacheSize(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsMaterialNode getCacheNode(uint n)
		{
			OdGsMaterialNode result = (OdGsMaterialNode)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsMaterialCache_getCacheNode(this.swigCPtr, n), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void addNode(OdGsBaseVectorizer view, OdDbStub mtl)
		{
			GlobalsPINVOKE.OdGsMaterialCache_addNode(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view), OdDbStub.getCPtr(mtl));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void clearCache()
		{
			GlobalsPINVOKE.OdGsMaterialCache_clearCache(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void invalidateCache()
		{
			GlobalsPINVOKE.OdGsMaterialCache_invalidateCache(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool saveMaterialCache(SWIGTYPE_p_OdGsFiler pFiler)
		{
			bool result = GlobalsPINVOKE.OdGsMaterialCache_saveMaterialCache(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool loadMaterialCache(SWIGTYPE_p_OdGsFiler pFiler)
		{
			bool result = GlobalsPINVOKE.OdGsMaterialCache_loadMaterialCache(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
